/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package gsoc.ogsadai.model.impl;

import gsoc.ogsadai.model.ModelPackage;
import gsoc.ogsadai.model.ParallelType;
import gsoc.ogsadai.model.PipelineType;
import gsoc.ogsadai.model.SequenceType;
import gsoc.ogsadai.model.WorkflowType;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Workflow Type</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link gsoc.ogsadai.model.impl.WorkflowTypeImpl#getParallel <em>Parallel</em>}</li>
 *   <li>{@link gsoc.ogsadai.model.impl.WorkflowTypeImpl#getSequence <em>Sequence</em>}</li>
 *   <li>{@link gsoc.ogsadai.model.impl.WorkflowTypeImpl#getPipeline <em>Pipeline</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class WorkflowTypeImpl extends EObjectImpl implements WorkflowType {
	/**
	 * The cached value of the '{@link #getParallel() <em>Parallel</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getParallel()
	 * @generated
	 * @ordered
	 */
	protected ParallelType parallel;

	/**
	 * The cached value of the '{@link #getSequence() <em>Sequence</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSequence()
	 * @generated
	 * @ordered
	 */
	protected SequenceType sequence;

	/**
	 * The cached value of the '{@link #getPipeline() <em>Pipeline</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPipeline()
	 * @generated
	 * @ordered
	 */
	protected PipelineType pipeline;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected WorkflowTypeImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return ModelPackage.Literals.WORKFLOW_TYPE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ParallelType getParallel() {
		return parallel;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetParallel(ParallelType newParallel, NotificationChain msgs) {
		ParallelType oldParallel = parallel;
		parallel = newParallel;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ModelPackage.WORKFLOW_TYPE__PARALLEL, oldParallel, newParallel);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setParallel(ParallelType newParallel) {
		if (newParallel != parallel) {
			NotificationChain msgs = null;
			if (parallel != null)
				msgs = ((InternalEObject)parallel).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ModelPackage.WORKFLOW_TYPE__PARALLEL, null, msgs);
			if (newParallel != null)
				msgs = ((InternalEObject)newParallel).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ModelPackage.WORKFLOW_TYPE__PARALLEL, null, msgs);
			msgs = basicSetParallel(newParallel, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.WORKFLOW_TYPE__PARALLEL, newParallel, newParallel));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public SequenceType getSequence() {
		return sequence;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetSequence(SequenceType newSequence, NotificationChain msgs) {
		SequenceType oldSequence = sequence;
		sequence = newSequence;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ModelPackage.WORKFLOW_TYPE__SEQUENCE, oldSequence, newSequence);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setSequence(SequenceType newSequence) {
		if (newSequence != sequence) {
			NotificationChain msgs = null;
			if (sequence != null)
				msgs = ((InternalEObject)sequence).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ModelPackage.WORKFLOW_TYPE__SEQUENCE, null, msgs);
			if (newSequence != null)
				msgs = ((InternalEObject)newSequence).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ModelPackage.WORKFLOW_TYPE__SEQUENCE, null, msgs);
			msgs = basicSetSequence(newSequence, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.WORKFLOW_TYPE__SEQUENCE, newSequence, newSequence));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public PipelineType getPipeline() {
		return pipeline;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetPipeline(PipelineType newPipeline, NotificationChain msgs) {
		PipelineType oldPipeline = pipeline;
		pipeline = newPipeline;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ModelPackage.WORKFLOW_TYPE__PIPELINE, oldPipeline, newPipeline);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setPipeline(PipelineType newPipeline) {
		if (newPipeline != pipeline) {
			NotificationChain msgs = null;
			if (pipeline != null)
				msgs = ((InternalEObject)pipeline).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ModelPackage.WORKFLOW_TYPE__PIPELINE, null, msgs);
			if (newPipeline != null)
				msgs = ((InternalEObject)newPipeline).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ModelPackage.WORKFLOW_TYPE__PIPELINE, null, msgs);
			msgs = basicSetPipeline(newPipeline, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.WORKFLOW_TYPE__PIPELINE, newPipeline, newPipeline));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case ModelPackage.WORKFLOW_TYPE__PARALLEL:
				return basicSetParallel(null, msgs);
			case ModelPackage.WORKFLOW_TYPE__SEQUENCE:
				return basicSetSequence(null, msgs);
			case ModelPackage.WORKFLOW_TYPE__PIPELINE:
				return basicSetPipeline(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case ModelPackage.WORKFLOW_TYPE__PARALLEL:
				return getParallel();
			case ModelPackage.WORKFLOW_TYPE__SEQUENCE:
				return getSequence();
			case ModelPackage.WORKFLOW_TYPE__PIPELINE:
				return getPipeline();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case ModelPackage.WORKFLOW_TYPE__PARALLEL:
				setParallel((ParallelType)newValue);
				return;
			case ModelPackage.WORKFLOW_TYPE__SEQUENCE:
				setSequence((SequenceType)newValue);
				return;
			case ModelPackage.WORKFLOW_TYPE__PIPELINE:
				setPipeline((PipelineType)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case ModelPackage.WORKFLOW_TYPE__PARALLEL:
				setParallel((ParallelType)null);
				return;
			case ModelPackage.WORKFLOW_TYPE__SEQUENCE:
				setSequence((SequenceType)null);
				return;
			case ModelPackage.WORKFLOW_TYPE__PIPELINE:
				setPipeline((PipelineType)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case ModelPackage.WORKFLOW_TYPE__PARALLEL:
				return parallel != null;
			case ModelPackage.WORKFLOW_TYPE__SEQUENCE:
				return sequence != null;
			case ModelPackage.WORKFLOW_TYPE__PIPELINE:
				return pipeline != null;
		}
		return super.eIsSet(featureID);
	}

} //WorkflowTypeImpl
